package com.mcy.springbatch.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobExecutionListener;
import org.springframework.stereotype.Component;

/**
 * Job级别的监听器，实现接口的方式
 */
@Slf4j
@Component
public class JobListener implements JobExecutionListener {

    @Override
    public void beforeJob(JobExecution jobExecution) {
        log.info("Job执行之前监听:{},status:{}",jobExecution.getJobInstance().getJobName(),jobExecution.getStatus());
    }

    @Override
    public void afterJob(JobExecution jobExecution) {
        log.info("Job执行之后监听:{},status:{}",jobExecution.getJobInstance().getJobName(),jobExecution.getStatus());
    }
}
